﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;

namespace BluePortal.Framework
{
    public class UserProfile
    {
        private string name = null;
        public string Name
        {
            get { return name ; }
            set { name  = value; }
        }

        private List<string> roles = new List<string>();
        public List<string> Roles
        {
            get { return roles; }
        }
	
    }

    public class WCFHelper
    {
        public static void AddUserProfile(string name)
        {
            AddUserProfile(new UserProfile().Name = name);
        }

        /// <summary>
        /// Add user profile to the WCF header
        /// </summary>
        /// <param name="profile"></param>
        public static void AddUserProfile(UserProfile profile)
        {
            OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("UserProfile.Login", "BluePortal", profile.Name));
            foreach (string role in profile.Roles) 
                OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("UserProfile.Roles", "BluePortal", role));            
        }
    }
}
